/*
 * @Descripttion:
 * @Author: YuZhenJing
 * @Date: 2020-01-01 11:53:29
 * @LastEditors: YuZhenJing
 * @LastEditTime: 2020-05-12 10:38:49
 */
const path = require('path')
const webpack = require('webpack')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
const copyWebpackPlugin = require('copy-webpack-plugin')
const outputPath = '../../../dist/asmMain'
module.exports = {
  entry: {
    app: './src/index.js',
  },
  mode: 'production',
  output: {
    path: path.resolve(__dirname, outputPath),
    filename: '[name].[hash].js',
    publicPath: '/',
  },
  module: {
    rules: [{ parser: { system: false } }],
  },
  plugins: [
    new HtmlWebpackPlugin({
      title: process.env.npm_package_productName,
      description: process.env.npm_package_description,
      template: './index.html',
    }),
    new webpack.DefinePlugin({
      'process.env': { mode: '"prod"', myIp: '"129.211.82.243"' },
    }),
    new CleanWebpackPlugin(),
    new copyWebpackPlugin([
      {
        from: path.resolve(__dirname, '../css'),
        to: path.resolve(__dirname, outputPath + '/css'),
      },
      {
        from: path.resolve(__dirname, '../images'),
        to: path.resolve(__dirname, outputPath + '/images'),
      },
      {
        from: path.resolve(__dirname, '../store'),
        to: path.resolve(__dirname, outputPath + '/store'),
      },
    ]),
  ],
}
